/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package projetCalendar.controllers;

import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;


public class PeriodeController extends HttpServlet {
   
    private String periodeActuelle = "jour"; 
    /** 
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String periode = request.getParameter("periode");
        String date_str = request.getParameter("dateJour");
      
        
        if (periode.equals(null)) {
            if (periodeActuelle.equals("jour")) {
                 response.sendRedirect(getServletContext().getContextPath()+"/jour?dateJour="+date_str);

            }
            if (periodeActuelle.equals("semaine")) {
                response.sendRedirect(getServletContext().getContextPath()+"/semaine?dateJour="+date_str);
            }
            if (periodeActuelle.equals("mois")) {
               response.sendRedirect(getServletContext().getContextPath()+"/mois?dateJour="+date_str);
            }
        }
        
       /* request.setAttribute("vuePartielle", "/WEB-INF/vues/Jour.jsp");
        request.setAttribute("dateJour", date_str);
        getServletContext().getRequestDispatcher("/WEB-INF/vues/Layout.jsp").forward(request, response);
        response.setContentType("text/html;charset=UTF-8");*/
    
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
    * Returns a short description of the servlet.
    */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}
